package com.mdinic.blogovi.front.page.forgotpass;

import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.spring.injection.annot.SpringBean;

import com.mdinic.blogovi.front.common.AbstractFormFeedbackPanel;
import com.mdinic.blogovi.service.PersonService;

class ForgotPasswordPanel extends AbstractFormFeedbackPanel<ForgotPasswordPanelModel> {

    private static final long serialVersionUID = 1396340274620808373L;

    @SpringBean
    private PersonService personService;

    public ForgotPasswordPanel() {
        super(ID, new ForgotPasswordPanelModel());

        getForm().add(new TextField<String>("email").setRequired(true));
    }

    @Override
    protected void submit(ForgotPasswordPanelModel object) {
        personService.forgotPassword(object.getEmail());
        setResponsePage(PasswordSentPage.class);
    }

}
